var vm = new Vue({
    el:"#app",
    data(){
        return {
            UserName:'',
            modal1:false,
            pwdFormItem:{
                UserName:'',
                Password:'',
                UserNo:''
            },
        }
    },
    created(){
        this.initThisPage();
    },
    methods:{
        ok(){},
        cancel(){},
        updatePassword(){
            var self = this;
            var UserNo = self.pwdFormItem.UserNo;
            var Password = self.pwdFormItem.Password;
            if(Password==null||Password==""){
                toastr.warning("新密码不准为空");
                return false;
            }
            var jsondata = {"UserNo":UserNo,"Password":Password};
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/updatePassword", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                data: data_json, //参数值
                type: "POST", //请求方式
                headers : {
                    'Content-Type' : 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    if(data.Status==1){
                        toastr.success("修改成功");
                        window.location.href="./login.html";
                    }else{
                        toastr.error("修改失败，请刷新页面后重试");
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function(data) {

                }
            });

        },
        initThisPage(){
            var self = this;
            $.ajax({
                url: "./goLogin/initIndexPage", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    if(data.Status==0){
                        window.location.href="../../login.html";
                    }else{
                        self.UserName = data.UserName;
                        self.pwdFormItem.UserName = data.UserName;
                        self.pwdFormItem.UserNo = data.UserNo;
                        var Lim = data.Lim;
                        var Bm = data.Bm;
                        if(Lim==0){
                            $("#IsOrNotProject").attr("style","");
                            $("#IsOrNotData").attr("style","");
                        }else if(Lim==1){
                            $("#IsOrNotData").attr("style","");
                        }else{
                            window.location.href="../../login.html";
                        }
                        var Store = data.Store;
                        if(Store!="运营管理中心"){
                            $("#JXSIsOrNot").attr("style","display:none");
                            $("#CPIsOrNot").attr("style","display:none");
                            $("#CGJHIsOrNot").attr("style","display:none");
                        }else{
                            $("#JXSIsOrNot").attr("style","");
                            $("#CPIsOrNot").attr("style","");
                            $("#CGJHIsOrNot").attr("style","");
                        }
                        if(Bm!="副总"&&Bm!='策划部'&&Bm!='办公室'){
                            $("#CylIsOrNot").attr("style","display:none");
                        }else{
                            $("#CylIsOrNot").attr("style","");
                        }
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        }
    }
})